import Vue from 'vue'
import Router from 'vue-router'
import login from '@/view/login' //登录
import index from '@/view/index/index' //首页
import Error500 from '@/view/errorpage/Error500' //首页
import Error403 from '@/view/errorpage/Error403' //首页
import Error404 from '@/view/errorpage/Error404' //首页
import home from '@/view/index/home' //首页
// 管理员信息
import admin_list from '@/view/powers/admin/admin_list'
import admin_add from '@/view/powers/admin/admin_add'
import admin_edit from '@/view/powers/admin/admin_edit'

//权限管理（角色）
import role_list from '@/view/powers/role/role_list'
import role_add from '@/view/powers/role/role_add'
import role_edit from '@/view/powers/role/role_edit'

// 系统设置
import system_lists from '@/view/system/index' // 系统设置
import advise_list from '@/view/system/advise_list' // 系统设置
import city_list from '@/view/system/city_list' // 城市列表

// 活动管理
import activity_list from '@/view/activity/index'
import activity_goods from '@/view/activity/goods' // 活动奖品
import activity_goods_add from '@/view/activity/goods_add' // 活动奖品添加

import award_history from '@/view/activity/award_history' // 中奖记录

// 广告
import adv_position from '@/view/adv/position' // 广告管理
import adv_list from '@/view/adv/adv_list' // 广告

// 用户管理
import member_list from '@/view/member/index'
import user_import from '@/view/member/user_import' // 政策导入结果显示
import member_apply from '@/view/member/member_apply' // 食堂正式会员申请
// 统计
import statistics from '@/view/count/member_statistic' // 用户统计
import random_statistic from '@/view/count/random_statistic' // 随机活动统计
import user_join_statistic from '@/view/count/user_join_statistic' // 用户参与情况统计

// 文章
import article_list from '@/view/article/index'

// 题库
import question_list from '@/view/question/index'
import question_import from '@/view/question/question_import'

Vue.use(Router)

// 修改重复点击报错的问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};

export default new Router({
  routes: [
    { path: '/Error500', name: 'Error500', component: Error500, }, //内部错误
    { path: '/Error404', name: 'Error404', component: Error404, }, //页面错误
    { path: '/Error403', name: 'Error403', component: Error403, }, //页面错误
    { path: '/auth/login', name: 'login', component: login }, //登录界面
    {
      path: '/',
      name: 'index',
      component: index,
      redirect: '/home',
      children: [
        { path: '/home', name: 'home', component: home }, //首页
        //权限管理
        { path: '/role_list', name: 'role_list', component: role_list },
        { path: '/role_add', name: 'role_add', component: role_add },
        { path: '/role_edit/:role_id', name: 'role_edit', component: role_edit },

        // 管理员
        { path: '/admin_list', name: 'admin_list', component: admin_list },
        { path: '/admin_add', name: 'admin_add', component: admin_add },
        { path: '/admin_edit/:id', name: 'admin_edit', component: admin_edit },
        // 活动管理
        { path: '/activity_list', name: 'activity_list', component: activity_list },
        { path: '/activity_goods', name: 'activity_goods', component: activity_goods }, // 活动奖品
        { path: '/activity_goods_add', name: 'activity_goods_add', component: activity_goods_add }, // 活动奖品
        { path: '/award_history', name: 'award_history', component: award_history }, // 中奖记录

        // 用户管理
        { path: '/member_list', name: 'member_list', component: member_list },
        { path: '/user_import', name: 'user_import', component: user_import }, // 导入结果
        { path: '/member_apply', name: 'member_apply', component: member_apply }, // 食堂正式会员申请

        // 广告
        { path: 'adv_position', name: 'adv_position', component: adv_position }, // 广告位
        { path: 'adv_list', name: 'adv_list', component: adv_list }, // 广告位
         // 统计
        { path: 'statistics', name: 'statistics', component: statistics }, // 用户统计
        { path: 'random_statistic', name: 'random_statistic', component: random_statistic }, // 随机活动统计
        { path: 'user_join_statistic', name: 'user_join_statistic', component: user_join_statistic }, // 用户参与活动统计

         // 文章
        { path: 'article_list', name: 'article_list', component: article_list },

        // 题库
        { path: 'question_list', name: 'question_list', component: question_list },
        { path: 'question_import', name: 'question_import', component: question_import }, // 导入结果

        // 系统管理
        { path: 'system_lists',name: 'system_lists', component: system_lists },
        { path: 'advise_list',name: 'advise_list', component: advise_list }, // 投诉建议
        { path: 'city_list',name: 'city_list', component: city_list }, // 城市管理
      ]
    }
  ]
})
